package xml改纯注解.config;

import Dao.stu;
import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;

import javax.sql.DataSource;


public class JdbcConfig {
    //1.定义一个方法获得要管理的对象
    @Value("${driver}")
    private String driver ;
    @Value("${url}")
    private String  url;
    @Value("${userName}")
    private String  userName;
    @Value("${password}")
    private String  password;
    @Bean
    public DataSource dataSource(stu st){
        DruidDataSource ds = new DruidDataSource();
        System.out.println(st);
        ds.setDriverClassName(driver);
        ds.setUrl(url);
        ds.setUsername(userName);
        ds.setPassword(password);
        return ds;
    }
}
